package study.alex.resumedb.gae;

import com.vaadin.data.util.converter.Converter;
import com.vaadin.data.util.converter.DefaultConverterFactory;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.logging.Logger;

/**
 * Created with IntelliJ IDEA.
 * User: alex
 * Date: 28.01.14
 * Time: 21:21
 * SVN $Id$
 */
public class AppConverterFactory extends DefaultConverterFactory {
    @Override
    public <PRESENTATION, MODEL> Converter<PRESENTATION, MODEL> createConverter(Class<PRESENTATION> presentationType, Class<MODEL> modelType) {
        if (Date.class == presentationType && GregorianCalendar.class == modelType) {
            Logger.getLogger(AppConverterFactory.class.getName()).info("Create new converter for GregorianCalendar");
            return (Converter<PRESENTATION, MODEL>) new DateConverter();
        }

        // Default to the supertype
        return super.createConverter(presentationType, modelType);
    }
}
